package com.zhuss.meeting.room;

import com.zhuss.bean.bo.meeting.room.CreateRoomBo;
import com.zhuss.bean.bo.meeting.room.DeleteRoomBo;
import com.zhuss.bean.bo.meeting.room.UpdateRoomBo;
import com.zhuss.common.OperateService;
import com.zhuss.common.Processor;
import com.zhuss.exception.WpsException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

/**
 * @Author: zhushanshuo
 * @Date: 2020/2/12 19:38
 */
@Component("roomOperateService")
public class RoomOperateService implements OperateService<Void,Object>{

    @Autowired
    @Qualifier("roomCreate")
    private Processor<Object, CreateRoomBo> roomCreate;

    @Autowired
    @Qualifier("roomUpdate")
    private Processor<Object, UpdateRoomBo> roomUpdate;

    @Autowired
    @Qualifier("roomDelete")
    private Processor<Object, DeleteRoomBo> roomDelete;

    @Override
    @Transactional(rollbackFor = Exception.class)
    public Void create(Object o) throws WpsException {
        CreateRoomBo bo = (CreateRoomBo) o;
        roomCreate.process(bo);
        return null;
    }

    @Override
    public Void update(Object o) throws WpsException {
        UpdateRoomBo bo = (UpdateRoomBo) o;
        roomUpdate.process(bo);
        return null;
    }

    @Override
    public Void delete(Object o) throws WpsException {
        DeleteRoomBo bo = (DeleteRoomBo) o;
        roomDelete.process(bo);
        return null;
    }

}
